package petshop.agronunes.entidade;
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "historico")
public class Historico implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private Integer pkCodigo;
	private Servico fkServico;
	private String dsHistorico;
	
	public Historico(){
		super();
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getPkCodigo() {
		return this.pkCodigo;
	}

	public void setPkCodigo(Integer pkCodigo) {
		this.pkCodigo = pkCodigo;
	}
	
	
	@ManyToOne(targetEntity = Servico.class, fetch = FetchType.EAGER)
	@JoinColumn(name = "fk_id_Servico", referencedColumnName = "pkCodigo", insertable = true, updatable = true)
	public Servico getFkServico() {
		return fkServico;
	}
	public void setFkServico(Servico fkServico) {
		this.fkServico = fkServico;
	}
	
	
	
	@Column(name = "ds_Historico", length = 50)
	public String getDsHistorico() {
		return this.dsHistorico;
	}

	public void setDsHistorico(String dsHistorico) {
		this.dsHistorico = dsHistorico;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((pkCodigo == null) ? 0 : pkCodigo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Historico other = (Historico) obj;
		if (pkCodigo == null) {
			if (other.pkCodigo != null)
				return false;
		} else if (!pkCodigo.equals(other.pkCodigo))
			return false;
		return true;
	}
	
}

